﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml.Serialization;
using System.IO;
using F_SER.Module;
using System.Net;
using System.Text;

namespace F_SER.DAL
{
    public static class CodeHelper
    {
        /// <summary>
        /// 将module 转换成xml
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public static string xml(Module.SysInfo user)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(SysInfo));
            MemoryStream stream = new MemoryStream();//创建内存的流
            serializer.Serialize(stream, user); //序列化user 并存放到内存流里

            string str = System.Text.Encoding.UTF8.GetString(stream.ToArray());//将内存流转换为string
            stream.Close();//释放内存
            string oldstr = "<?xml version=\"1.0\"?>";
            str = str.Replace(oldstr, "<?xml version=\"1.0\" encoding=\"GB2312\"?>").ToLower();
            return str;
        }

    }
}